#ifndef LASERCONTROL_H
#define LASERCONTROL_H

#include <QObject>
#include <QString>
#include <QByteArray>
#include <QCoreApplication>
#include <global_defines.h>
#include <QTime>
#include "serialportthread.h"
#include "device_base/lasercontrol_base.h"

class LaserControl_KO : public LaserControlBase
{
    Q_OBJECT
public:
    explicit LaserControl_KO(LaserControlBase *parent = nullptr);
    void OpenLaser(const SOFTWARESETTINGS mysetting);
    void OpenLaserProcess(const SOFTWARESETTINGS mysetting);
    void CloseLaser();
    void laserTest(const SOFTWARESETTINGS mysetting);


private slots:
    void PortError(const QString &s);
    void laserReceiveResp(const QByteArray response);

public slots:
    void ReadCaseTemperature();
    void ReadDiodeTemperature();
    void emissionStateCheck();//Read the state of emission

private:
    void diodeCurrentSet(double current);//Write the booster diode current set point
    void checkLaser();//Read Alarms
    void mySleep(unsigned int msec);
    void requestQueue(QString a);
    void transact();

    QString errorCode;
    int fireStep, closeStep, requestNum, queueNum;

    int baud, waitTimeout, waitForReadyReadTime;
    int diodeCurrent;//booster diode current
    uint laserCurrent;

    QString request, queue[5];

    unsigned int waitTime;
    bool  isCurrentSetting, isFiring, isClosing, isChecking, isSetting,isON;

    serialportThread *LaserportThread;
    SOFTWARESETTINGS settings;
};

#endif // LASERCONTROL_H

